﻿@model RentalSystem.Data.EF.Agencies


@if (ViewBag.FormMode == Web.Helper.Mode.Edit)
{
    using (Html.BeginForm("LocationUpdate", "Workers", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        if (Model.Files != null && Model.Files.FileUrl != null)
        {
            <img class="cover" src='@String.Format("../../Uploads/{0}", Model.Files.FileUrl)' alt="cover" />
        }
        else
        {
            <img class="cover" src="../../Uploads/location_unknown.jpg" alt="cover" />
        }
        
        <div class="column">
            <div class="ResultError">@Html.ValidationSummary()</div>

            <h3>Nazwa: @Html.TextBoxFor(x => x.AgencyName)</h3>
            @Html.HiddenFor(x => x.AgencyID)
            @Html.HiddenFor(x => x.AgencyTypeID)
            <table>
                <tr><td>Adres:</td><td>@Html.TextBoxFor(x => x.AgencyAddress)</td></tr>
                <tr><td>Miasto: </td><td>@Html.TextBoxFor(x => x.AgencyCity)</td></tr>
                <tr><td>Kod pocztowy: </td><td>@Html.TextBoxFor(x => x.AgencyZipCode)</td></tr>
                <tr><td>Punkt aktywny: </td><td>@Html.CheckBoxFor(x => x.AgencyIsActive)</td></tr>
                <tr><td>Data utworzenia: </td><td>@Html.TextBoxFor(x => x.AgencyCreatedDate)</td></tr>
            </table>
            <p>Przypisanych klientów: @Model.Users.Count</p>
            <p>Całkowita liczba nośników: @Model.Discs.Count</p>
            <p>Zdjęcie:<input type="file" name="imageFile" /></p>
        </div>
            
    
        <div class="verticalAcionIcons">
            <input type="submit" value="" class="save" />
            <a href='@String.Format("location/{0}/delete", Model.AgencyID)' class="delete"></a>
        </div>
    }
}
else if (ViewBag.FormMode == Web.Helper.Mode.Create)
{
    using (Html.BeginForm("LocationAdd", "Workers", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        if (ViewBag.ActionResult != null)
        {
         <div class="ResultOk">@ViewBag.ActionResult</div>
        }
    
        <div class="ResultError">@Html.ValidationSummary()</div>
    
            <div class="form">

                <div class="formtitle">Nowa wideoteka:</div>
            
                <div class="input">
			        <div class="inputtext">Nazwa:</div>
			        <div class="inputcontent">
				        @Html.TextBoxFor(w => w.AgencyName)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(w => w.AgencyName)
                        </div>
			        </div>
		        </div>

                <div class="input">
			        <div class="inputtext">Miasto:</div>
			        <div class="inputcontent">
				        @Html.TextBoxFor(w => w.AgencyCity)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(w => w.AgencyCity)
                        </div>
			        </div>
		        </div>

		        <div class="input">
			        <div class="inputtext">Kod pocztowy:</div>
			        <div class="inputcontent">
				        @Html.TextBoxFor(w => w.AgencyZipCode)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(w => w.AgencyZipCode)
                        </div>
			        </div>
		        </div>

		        <div class="input">
			        <div class="inputtext">Adres:</div>
			        <div class="inputcontent">
				        @Html.TextBoxFor(w => w.AgencyAddress)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(w => w.AgencyAddress)
                        </div>
			        </div>
		        </div>

                <div class="input">
			        <div class="inputtext">Zdjęcie:</div>
			        <div class="inputcontent">
				        <input type="file" name="imageFile" />
			        </div>
		        </div>

                <div class="buttons">
				    <input class="orangebutton" type="submit" value="Dodaj wideotekę" />
				    <input class="greybutton" type="reset" value="Wyczyść" />
			    </div>
        </div>
    }
}
else
{
    if (Model != null && Model.Files != null && Model.Files.FileUrl != null)
    {
            <img class="cover" src='@String.Format("http://{0}/Uploads/{1}", Request.Url.Host, Model.Files.FileUrl)' alt="cover" />
    }
    else
    {
              <img class="cover" src='@String.Format("http://{0}/Uploads/movie_unknown.jpg", Request.Url.Host)' alt="cover" />
    }

        <div class="column">
            <h3>@Model.AgencyName</h3>
            <p>@Model.AgencyAddress</p>
            <p>@Model.AgencyCity</p>
            <p>@Model.AgencyZipCode</p>
        </div>

        <div class="column">
            @if (Model.AgencyIsActive)
            {
                <p style="padding-left: 25px; background:url('../../Content/images/icons/active.png') left center no-repeat; color: Green;">Punkt aktywny</p> 
            }
            else
            {
                 <p style="padding-left: 25px; background:url('../../Content/images/icons/inactive.png') left center no-repeat; color: Red;">Punkt nieaktywny</p>
            }
            
            <p>Data utworzenia: @Model.AgencyCreatedDate.ToString("dd.MM.yyyy")r</p>
            <p>Przypisanych klientów: @Model.Users.Count</p>
            <p>Całkowita liczba nośników: @Model.Discs.Count</p>
        </div>
    
    if(ViewBag.IsUserLogged)
    {
        <a href='@String.Format("http://{0}/customers/selectAgency/{1}", Request.Url.Host, Model.AgencyID)'>Wybierz agencję</a>
    }
}
        
    